Hi picass,

Deine Freiheit die Antriebssteuerung mit 2xNE555 durchzufuehren, sei Dir unbenommen. Nur befreit Dich die Software eines PIC von zusaetzlichen Bauteilen, Verbindunngen und Komplikationen. Einstellungen lassen sich unkombliziert vornehmen.
Info: Ich bin nahe der 80 und habe das auch hinbekommen!

Beiliegend eine Uebersicht, wie einfach sich das Alles per Software locker erledigen laesst. Ich habe das mal so zusammengestellt und hoffe nichts Wesentliches dabei uebersehen zu haben.

Ja, zugegeben ich musste mich auch kraeftig durchbeissen, bis ich es geschluckt habe! Man kann ja probieren, studieren und macht dabei (hoffentlich) kaum was kaputt, ausser der aufgewendeten Zeit.

Wichtig ist nur, dass Du die Initialisierung hinbekommst. Mit einem Oszi ist es dann leicht die Auswirkungen bei Awnderung der PWM-bestimmenden Parameter zu verfolgen.

Ansonsten: Viel Erfolg bei der Vollendung Deines Hochwasser-Problems im Keller!

mfG Ottmar

Nach der Initialisierung brauchst Du nur noch die Zustaende Deiner Richtungspoti per ADC auszulesen und als Wert den PWM-Timern, bzw als 0 oder 1 den EN-Eingaengen fuer die Motorumpolung des L298 zuzuweisen.

Mit 2 Kreuzknueppeln ermoeglicht dies ohne Mehraufwand die linke und die rechte Raupe voellig unabhaengig voneinander zu steuern.

Die Fahrgeschwindigkeit wird einfach vom ADC-Wert des entsprechenden Richtungspoti abgenommen z.B 
VORWAERTS=1024-518 STOP=512+-5(Neutralbereich) RUECKWAERTS 506-0

Hnweis: Einzelne Grossbuchstaben (A-Z,0-1) sind ASCII-Befehle der App welche per Bluetooth gesendet und direkt als solche ausgewertet werden.

----------
 
Diese Zeilen legen die Initialisierung fuer 2xPWM beim 16F1936 fest:

1. Enable TMR2,TMR4 noPre-/Postscaler
   movlw    b'00000100'    ;b2=1 TMR2/4 is on
   movwf    T2CON          ;-> CCP2
   movwf    T4CON          ;-> CCP1
   ;
;  2. Load CCPRxL and DCxBx bits of CCPxCON with PWM duty cycle value.
   movlw    .178           ;Value set DC to 0% ->PWM OFF
   movwf    CCPR1L         ;CCPR1L:CCP1CON,DC1B
   movwf    CCPR2L         ;CCPR2L:CCP2CON,DC2B
   ;
;  3. Configure the ECCP modules to be usedOnce the SINGLE OUTPUT mode
   movlw    b'00001100'    ;PWM mode: PxA, PxC, PxB, PxD active-high
   movwf    CCP1CON        ;          P1A=RC2
   movwf    CCP2CON        ;          P2A=RC1
   ;
;  4. PWM STEERING MODE
   clrf     PSTR1CON
   bsf      PSTR1CON,STR1A ;b0=1 = P1A pin has the PWM waveform with
   clrf     PSTR2CON       ;polarity control from CCPxM<1:0>
   bsf      PSTR2CON,STR2A ;b0=P2A pin has the PWM waveform from 
   ;                       ;CCPxCON,CCPxM<1:0>
;  5. PWM-Frequenz
   movlw   .101            ;f_PWM=11,3kHz at fosc=8MHz
   movwf    PR2            ;PWM-Periodregister TMR2
   movwf    PR4            ;PWM-Periodregister TMR4
   ;
-------------------------
Geschwindigkeitssteuerung
-------------------------
Cmd_Speed:
; THE VARIABLE DCX IS ONLY CHANGED IN THIS SUB!
; The maximum PWM-DC depends on the value in the period register PR2!
; Currently PR2 = 101 speed step 10 = DC 101!
; The control-related travel speed is set only via tmpDCx and CCPRxL 
;----
; In der Sub wird der ADC-Wert der Potis ausgelesen und als Duty Cycle
; an CCPRxL zugewiesen
; Von der Potistellung wird die Farhtrichtungrichtung abgeleitet und als
; Bitwert 0/1 an DC2,DC1 zugewiesen.
;----
cmd_speed_set:             ;Value of DC2:1 is in WREG
   movwf    DutyCycle
   movwf    tmpDC2         ;tmpDC2:1 are changeable (e.g. cornering)
   movwf    tmpDC1
   ;
   BANKSEL  CCPR2L         ;both drives same DC -> same speed
   movwf    CCPR2L
   movwf    CCPR1L     
   BANKSEL  0
   ;
cmd_speed_end: 
   RETURN
;-----------------------------------
Cmd_Set_PWM:
   movf     tmpDC2,w
   BANKSEL  CCPR2L
   movwf    CCPR2L
   BANKSEL  0
   movf     tmpDC1,w
   BANKSEL  CCPR1L   
   movwf    CCPR1L
   BANKSEL  0
   RETURN 
   ;
;-------------------------------------------
;Auswertung Geschwindigkeit und Fahrtrichtung
---------------------------------------------
;*********************************************************************
Cmd_Drive:
; Die von mir verwendete Bluetooth-App sendet fuer die Geschwindigkeit ; den Ascci-code der Zahlen von 0-9 und mit den Buchstaben A-Z den Code ; fuer die Fahrtrichung.
;
; Evaluate received command and execute the command, if the character
; in the WREG matches the character in the tmpREG.
;
; Bluetooth commands
; See in File '16F1936_RoboCar2023.ASM' COMMANDS SEND BY APP
;
; The current command is output in LCD Line1+0 in the  debug menu,
; For error control, the direction of travel + right/left is assigned
; to the variables Info2:1, which are displayed in LINE2+0 of the LCD.
; e.g. "BL" for Backward+Left.
;
; The PWM DC depends on the max. value of the period registers PR2:4
; DutyCycle is generally set in sub Cmd_Speed
; Drive1:   LEFT side drive      
; Drive2:   RIGHT side drive
; DC1:      Duty Cycle LEFT side drive
; DC2:      Duty Cyle RIGHT side drive
; Info1:    direction char F,B,S for output in the LCD 
; Info2:    direction char L,R   "   "      Left/Right
;--------------------------------------------------------
;L298_PORT,b3:0     EN1 EN2 EN3 EN4
;FORWARD       0000  0   1   0   1  Links, rechts, vorwärts    
;BACKWARD      0000  1   0   1   0  Links, rechts, rückwärts
;STOP          0000  0   0   0   0  EN1=ENs EN3=EN4
;ROTATE_LEFT   0000  1   0   0   1  Rechts vorwärts, links rückwärts
;ROTATE_RIGHT  0000  0   1   1   0  Links vorwärts, rechts rückwärts		
;FORWARD    EQU   00000101
;BACKWARD   EQU   00001010
;ROTATE_L   EQU   00001001
;ROTATE_R   EQU   00000110
;
;  MOTOR 1
;  Pin   Turn Right  Turn Left   STOP
;  EN1   HIGH        LOW         EN1=EN2  L298_PORT,b0 (EN1)
;  EN2   LOW         HIGH                 L298_PORT,b1 (EN2) 
;---------------------------------------------------------
;  MOTOR 2
;  Pin   Turn Right  Turn Left   STOP
;  EN3   HIGH        LOW         EN1=EN2  L298_PORT,b2 (EN3)
;  EN4   LOW         HIGH                 L298_PORT,b3 (EN4)
;
;  Left side   right side
;  EN4   EN3   EN2   EN1   L298 ENA-connectors
;  0     1     0     1     car straight forward          (F)
;  1     0     1     0     car straight backward         (B)
;  0     1     1     0     Car rotates left on the spot  (L)
;  1     0     0     1     Car rotates right on the spot (B)
;
;  Driving rounded curves  (F+L, F+R, B+L, B+R 
;  Duty Cycle (DC) for the drive on the outside of the curve is
;  maintained, the DC for the inside is halved.
;
cmd_drive_F:
   movlw    "F"               ;command "FORWARD" (send by Bluetooth)
   xorwf    tmpRCREG,w        ;compare received Command-Char
   btfss    STATUS,Z          ;Z=1? Does WREG match tmpRCREG?
   GOTO     cmd_drive_B       ;No, try next possible Rx command
   movf     tmpRCREG,w        ;display "F " in LCD LINE2 Dig.0-1
   movwf    Info1
   movlw    " "
   movwf    Info2
   ;
   movf     DutyCycle,w       ;generally DC was set in Cmd_Speed
   movwf    tmpDC1
   movwf    tmpDC2
   CALL     Cmd_Set_PWM       ;set CCPR1L,CCPR2L
   movlw    FORWARD           ;Set EN4:1 to forward
   GOTO     cmd_drive_L298    ;copy EM3:0 to L298_LAT
   ; 
cmd_drive_B:   
   movlw    "B"               ;BACKWARD
   xorwf    tmpRCREG,w
   btfss    STATUS,Z
   GOTO     cmd_drive_S
   movf     tmpRCREG,w        ;"B " Info in Zeile 2 Dig.0-1
   movwf    Info1
   movlw    " "
   movwf    Info2
   ;
   movf     DutyCycle,w       ;generally DC was set in Cmd_Speed
   movwf    tmpDC1
   movwf    tmpDC2
   CALL     Cmd_Set_PWM         ;set CCPR1L,CCPR2L
   movlw    BACKWARD
   GOTO     cmd_drive_L298
;......usw....usw
   RETURN
;*********************************************************************
Cmd_Speed:
; Wegen der stufenweisen Steuerung konnte hier kein kontinuierlicher 
; ADC-Wert eines Poti verwendet werden. Der Duty Cycle wurde daher
; entsprechend den Stuerungsbefehlen 0-10 ("0"-"9","q") in Stufen zu 10 
; Prozent eingeteilt.
; 
;
; THE VARIABLE DCX IS ONLY CHANGED IN THIS SUB!
; The maximum PWM-DC depends on the value in the period register PR2!
; Currently PR2 = 101 speed step 10 = DC 101!
; The control-related travel speed is set only via tmpDCx and CCPRxL 
;
; The ASCII value in tmpRCREG is assigned a corresponding PWM value
; tmpRCREG = "0"        -> Speed 0     MOTOR OFF
; "          "1..9"     -> Speed 1..9  (1 starts with minimum PWM) 
; tmpRCREG = "q"        -> Speed 10    (predeterminated final speed)
   ;
cmd_speed_0:               
   movlw    "0"            ;SPEED 0 Ascii 48
   xorwf    tmpRCREG,w
   btfss    STATUS,Z
   GOTO     cmd_speed_1
   movlw    .0            
   GOTO     cmd_speed_set  ;tmpRCREG = "0" Set PWM-DC = 0
   ;
cmd_speed_1...9....

cmd_speed_10:      
   movlw    "q"            ;SPEED 100% of PR2 
   xorwf    tmpRCREG,w
   btfss    STATUS,Z
   GOTO     cmd_speed_end
   movlw    .101           ;tmpRCREG = "q" set DC1:2 = PR2 valzue
;   GOTO     cmd_speed_set  ;drive1:2 is fully switched on
   ;
cmd_speed_set:             ;Value of DC2:1 is in WREG
   movwf    DutyCycle
   movwf    tmpDC2         ;tmpDC2:1 are changeable (e.g. cornering)
   movwf    tmpDC1
   ;
   BANKSEL  CCPR2L         ;both drives same DC -> same speed
   movwf    CCPR2L
   movwf    CCPR1L     
   BANKSEL  0
   ;
cmd_speed_end: 
   RETURN